# coding=utf-8
import smtplib
from email.mime.text import MIMEText
from email.header import Header

# 发送邮箱
sender = '675696416@qq.com'

# 发送邮箱服务器
smtpserver = 'smtp.qq.com'


# username = '675696416@qq.com'  # 发送邮箱用户
# password = ''  # 邮箱密码或授权码

# 编写 text 类型的邮件正文
# msg = MIMEText('<html><h1>比你更忙的人都在学习！</h1></html>', 'html', 'utf-8')

# msg 的类型为 支持HTML的语法
def send_mail(user_name, password, subject, receiver, msg):
    msg = MIMEText(msg, 'html', 'utf-8')
    # 发送邮件主题
    msg['Subject'] = Header(subject, 'utf-8')
    # 发件人
    msg['From'] = '675696416@qq.com'
    # 收件人 receiver = []
    msg['To'] = ','.join(receiver)
    smtp = smtplib.SMTP()
    smtp.connect(smtpserver, 25)
    smtp.login(user_name, password)  # 登陆邮箱
    smtp.sendmail(msg['From'], msg['To'].split(','), msg.as_string())  # 发送邮件！
    print("邮件发送成功!")
